package com.gary.cmakejniapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.ConditionVariable;
import android.util.Log;

public class MainActivity extends AppCompatActivity {
    public static String TAG = "MainActivity";
    public static Context context;
    public static Activity activity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = this;
        activity = this;

        JniModule jm = new JniModule();
        jm.setString("This is a String from Java");
        String getstring = jm.getString();
        Log.d(TAG, getstring);
        //
        int iValue = 100;
        jm.setInt(iValue);
        int retInt = jm.getInt();
        Log.d(TAG, "Java get a int from C++,value is : " + retInt);
        // float
        float fValue = 3.333f;
        jm.setFloat(fValue);
        float retFloat = jm.getFloat();
        Log.d(TAG, "Java get a float from C++,value is : " + retFloat);
        //bool
        jm.setBool(true);
        boolean retBool = jm.getBool();
        if(retBool)
        {
            Log.d(TAG, "Java get a bool from C++,value is : true");
        }
        else
        {
            Log.d(TAG, "Java get a bool from C++,value is : false");
        }
        // Array
        int [] ia = {1,2,3,4,5,6,7,8,9,10};
        float[] fa = {1.1f,2.2f,3.3f,4.4f,5.5f,6.6f,7.7f,8.8f,9.9f,10.10f};
        JniModule.nativeTouchesMove(ia,fa);
        int[] array = JniModule.getNativeTouchesMove();
        Log.d(TAG, "get int array from C++ by return value");
        for(int i : array)
        {
            Log.d(TAG, "value is: " + i);
        }
        JniModule.getIntArray(array);
        Log.d(TAG, "get int array from C++ by parameter");
        for(int i : array)
        {
            Log.d(TAG, "value is: " + i);
        }

        jm.GetDiskFilesDirFromJava();
        jm.SetstrFromCppToJava();
    }
}
